#ifndef __UPGRADE_CCM4201S_H__
#define __UPGRADE_CCM4201S_H__

#include "intf_usb.h"


#define CCM4201S_FW_V               "CCM4201S_FW_V"


#define CCM4201S_FW_FILE_SIZE_MAX   (1*1024*1024)
#define CCM4201S_FW_FILE_SIZE_MIN   (10*1024)


#define CCM4201S_BOOT_USB_VID 0x2fd0
#define CCM4201S_BOOT_USB_PID 0x0000


#define CCM4201S_BOOT_TRANSFER_TIMEOUT 1000

#define CCM4201S_DOWNLOAD_PAGE_LEN   4096

#define CCM4201S_FLASH_BASE_ADDR    0x10001000

#define CCM4201S_DOWNLOAD_DATA_LEN_MAX   32768


typedef enum _CCM4201S_DOWNLOAD_CMD_ENUM
{
    CCM4201S_CMD_SELF_TEST = 0xC7,
    CCM4201S_CMD_SECURITY_CODE = 0xCC,
    CCM4201S_CMD_ERASE_EFLASH = 0xD3,
    CCM4201S_CMD_DOWNLOAD_CODE_TO_EFLASH = 0xD7,
    CCM4201S_CMD_CHECK_CRC = 0xD8,
    CCM4201S_CMD_DOWNLOAD_CRC_VALUE = 0xD9,
    CCM4201S_CMD_RUN_APP = 0xE3,
    CCM4201S_CMD_READ_SN = 0xA0,
    CCM4201S_CMD_READ_EFLASH = 0xD0,
    CCM4201S_CMD_ENABLE_WRITE_PROTECT = 0xD2,
    CCM4201S_CMD_DISABLE_WRITE_PROTECT = 0xD5,
    CCM4201S_CMD_ENABLE_READ_PROTECT = 0xDA,
    CCM4201S_CMD_DISABLE_READ_PROTECT = 0xD4,
    CCM4201S_CMD_RESET = 0xCB,
    CCM4201S_CMD_READ_CRC = 0xA6,
}CCM4201S_DOWNLOAD_CMD_ENUM;


typedef struct _CCM4201S_UPGRADE_PARAM_
{
    INTF_USB_HANDLE_STRUCT usb_handle;
    INTF_USB_ID_STRUCT usb_id;

    char ccm4201s_boot_version[64];
    uint8 sha1_result[20];
    //download protocal
}CCM4201S_UPGRADE_PARAM;


extern int32 ccm4201s_upgrade_module_init(CCM4201S_UPGRADE_PARAM *this);
extern int ccm4201s_upgrade_and_run(CCM4201S_UPGRADE_PARAM *this, char *file_path);


#endif //__UPGRADE_H__

